package com.xiaohao.springbootadmintemplate.controller;

import com.xiaohao.springbootadmintemplate.bean.User;
import com.xiaohao.springbootadmintemplate.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TestController{
    @Autowired
    private UserDao userDao;


    @PostMapping("/users")
    @PreAuthorize("hasRole('ADMIN')")
    public List<User> getUsers() {
        return userDao.findAll();
    }


    @PostMapping("/test")
    public String Test() {
        return "test";
    }
}
